import { createRouter, createWebHistory } from 'vue-router'

//给路由添加meta指定类型
declare module 'vue-router' {
  interface RouteMeta {
    menu?: boolean
    title?: string
    icon?: string
    auth?: boolean
  }
}

const routes =  [
    {
      path: '/',
      name: 'home',
      redirect: '/home',
      component: () => import('@/layout/index.vue'),
      meta:{
        menu: true,
        title: '首页',
        icon: 'document-copy',
        auth: true
      },
      children: [
        {
          path: '/home',
          name: 'home',
          component: () => import('@/views/Home/index.vue'),
          meta: {
            menu: true,
            title: '首页',
            icon: 'calendar',
            auth: true
          }
        },
        {
          path: '/exception',
          name: 'exception',
          component: () => import('@/views/Exception/index.vue'),
           meta: {
            menu: true,
            title: '考勤异常查询',
            icon: 'warning',
            auth: true
          }
        },
        {
          path: '/check',
          name: 'check',
          component: () => import('@/views/Check/index.vue'),
           meta: {
            menu: true,
            title: '我的考勤审批',
            icon: 'finished',
            auth: true
          }
        },
        {
          path: '/apply',
          name: 'apply',
          component: () => import('@/views/Apply/index.vue'),
           meta: {
            menu: true,
            title: '添加考勤审批',
            icon: 'document-add',
            auth: true
          }
        }
      ]
    },
    {
      path: '/login',
      name: 'login',
      component: () => import('@/views/Login/index.vue')
    }
  ]

const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes
})

export default router
